package com.bjsxt.controller;

import com.bjsxt.model.LoginResult;
import com.bjsxt.service.SysLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * description:
 * 登录的控制层
 *
 * @author ALIENWARE <br />
 * @date 2021/6/24
 */
@RestController
@Api(tags = "登录的控制器")
public class SysLoginController {

    /**
     * 登录的接口
     */
    @Autowired
    private SysLoginService sysLoginService;

    /**
     * 后台管理人员登录
     *
     * @param userName 用户名
     * @param password 密码
     * @return 登录返回值对象
     */
    @PostMapping("/login")
    @ApiOperation(value = "后台管理人员登录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username", value = "用户名", dataType = "String", paramType = "query", example = "admin"),
            @ApiImplicitParam(name = "password", value = "密码", dataType = "String", paramType = "query", example = "admin")
    })
    public LoginResult login(@RequestParam("username") String userName, String password) {
        // 调用业务层进行登录操作
        return sysLoginService.login(userName, password);
    }
}
